package com.tt.vtg.boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;

import com.tt.vtg.env.VtgDBEnv;

@Configurable
@ComponentScan({"com.tt.vtg"})
@Import(VtgDBEnv.class)
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class, 
								MongoDataAutoConfiguration.class})
//@EnableDiscoveryClient
public class AuthManagerApplication {
	@Autowired
	private Environment env;
	
	@Bean
	public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory(){
		TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
		tomcat.setContextPath(env.getProperty("server.context"));
		tomcat.setPort(Integer.valueOf(env.getProperty("server.port")));
		
		return tomcat;
	}
	
	public static void main(String[] args) {
		SpringApplication.run(AuthManagerApplication.class, args);
	}
}
